class NumArray {
    private int[] sum;

    public NumArray(int[] nums) {
        sum = new int[nums.length];
        for(int i =0;i<nums.length;i++){
            if(i==0){
                sum[i] = nums[i];
                continue;
            }
            sum[i]= nums[i]+sum[i-1];
        }
    }

    public int sumRange(int i, int j) {
        int temp = i > 0 ? sum[i-1] : 0;
        return sum[j] - temp;
    }

}

/**
 * Your NumArray object will be instantiated and called as such:
 * NumArray obj = new NumArray(nums);
 * int param_1 = obj.sumRange(i,j);
 */